<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c"       uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
     <meta http-equiv="content-Type" content="text/html; charset=utf-8" />
    <title>用户信息设置</title>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="blog,图片,david" />
	<meta http-equiv="description" content="This is my web blog" />
	
<link href="<%=path %>/themes/css/index.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/themes/css/pmanager.css" rel="stylesheet" type="text/css" />
 
   <script type="text/javascript" src="<%=path %>/script/jquery.js"></script>
 
<style type="text/css">
.warning{

}
.code{
  font-size:12px;
}

</style>
<script type="text/javascript">
 //提交，最终验证。
 $(function(){ 
 //初始化城市
 var city = $('#nowHome_1').val();
		if(city==null||city==''){
		$("#nowHome").attr("value",'北京');
		}else{
		$("#nowHome").attr("value",city);
		}
 
  $('form :input').blur(function(){
	         var id = $(this).attr("id");
             $(this).removeClass("warning").parents("td")
			 .find("span.error").remove()
			 .end()
			 .find("span.ok").remove();

		     var $listItem =  $(this).parents("td").find("span:last");
 
          if( id == 'password1'){
                var pass = $("#pass_old").val();
				if($(this).attr("value") == null || $(this).attr("value") == '' || $(this).attr("value").length<6 || $(this).attr("value").length>12){
                      var errorMsg = '密码必须大于6位小于12位!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
				     if($(this).attr("value") == pass){
				       var okMsg = '';
                       $(this).parent().next().text(okMsg)
				     }else{
                       var errorMsg = '和原密码不一致,请检查密码大小写!';
					   $('<span class="error"></span>').css("color","red")
					   $(this).parent().next().text(errorMsg)
					   .appendTo($listItem);
					  $(this).addClass("warning");
                       }
                       }
			 
				
			 }
			  if( id == 'password' ){
				if($(this).attr("value") == null || $(this).attr("value") == '' || $(this).attr("value").length<6 || $(this).attr("value").length>12){
                      var errorMsg = '密码必须大于6位小于12位!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
                       var okMsg = '';
                       $(this).parent().next().text(okMsg)
                       }
	
			 }
			   if( id == 'password2' ){
			    var pass2 = $("#password").val();
				if($(this).attr("value") == null || $(this).attr("value") == '' || $(this).attr("value").length<6 || $(this).attr("value").length>12){
                      var errorMsg = '密码必须大于6位小于12位!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
                       if($(this).attr("value") == pass2){
				       var okMsg = '';
                       $(this).parent().next().text(okMsg)
				     }else{
                       var errorMsg = '重复密码和新密码不一致!';
					   $('<span class="error"></span>').css("color","red")
					   $(this).parent().next().text(errorMsg)
					   .appendTo($listItem);
					  $(this).addClass("warning");
                       }
                       }			
			 }
			 
		      })
 
		$("#tijiao").bind("click", function(){
		$(":input").trigger('blur');
		
			var numWarning = $('.warning',$('form')).length;
			
            if(numWarning){
			    var errorFieldList = [];
                $(".warning").each(function(){
					errorFieldList.push( $(this).prev("span").text() );
				})
				
				return false;
			}  
			var password =  $('#password').val();
			var sendData="password="+password;
			$.ajax({
            type:"POST",
            url: "<%=request.getContextPath()%>/updateAccount.do", 
            dataType:'html', //接受数据格式
            async: false,
            data: sendData,

             success: function(data){ 
           
                    $("#loadtip2").show();  
                 
                },
           error:function(data){
             alert(data);
           }
            }) 
      });
       }) 
function refrash(){
		$('#imgId')[0].src+='?'+Math.floor(Math.random()*10);
		}
</script>
</head>

<body>
<%@ include file="../../../../common/header.jsp" %>
<div id="container">
<div id="mainbody">
  <div id="managerleftbody">
     <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我的设置</h2>
	  <ul>
	    <li class="lefttitle">信息设置</li>
	   <li><a href="<%=request.getContextPath()%>/userinfoset.do">基本信息</a></li>
	   <li><a href="<%=request.getContextPath()%>/pages/topics/usermanager/updateUserface.jsp">更换头像</a></li>
	   <li><a href="<%=request.getContextPath()%>/moreUserinfo.do">详细信息</a></li>
		 <li>帐户设置</li> 
	  </ul>
	  
	  <ul>
	    <li class="lefttitle">作品管理</li>
	   <li><a href="<%=request.getContextPath()%>/usertopicmanager.do">发布的作品</a></li>
	   <li><a href="<%=request.getContextPath()%>/usercollect.do">收藏的作品</a></li>
	   <li><a href="<%=request.getContextPath()%>/usercomment.do">评论的作品</a></li> 
	  </ul>
	   <ul>
	    <li class="lefttitle">站内动态</li>
	   <li><a href="javascript:alert('功能暂未启用')">全站动态</a></li>
		 <li><a href="javascript:alert('功能暂未启用')">我的好友</a></li>
	   <li><a href="javascript:alert('功能暂未启用')">好友动态</a></li>
	    
	  </ul>
  </div>
   <div id="managerrightbody">
	   <div class="ClassTitle">基本信息设置</div>
	   <form method="post" action="">
		<table>
		 <tr><td>
	 <div style="display:none;" id="loadtip2"><img src="<%=path%>/themes/images/success.gif"　width="30px" height="20px"/><font color="red">基本帐户信息成功</font></div> 
	 </td></tr>
	      <input type="hidden" id= "pass_old" value="${user.password}"/>
		  <tr>
		   <td>网站登录原密码:</td><td><input type="password"  name="password1" id="password1" value=""/></td><td class="regtip"></td>
		  </tr>
		  <tr>
		   <td>网站登录新密码:</td><td><input type="password"  name="password" id="password" value=""/></td><td class="regtip"></td>
		  </tr>
		  <tr>
		   <td>重复新密码:</td><td><input type="password"  name="password2" id="password2" value=""/></td><td class="regtip"></td>
		  </tr>
		  <tr>
		   <td  colspan="2" align="center"><br /><input type="button"  id="tijiao" value="提交" /><input type="button" value="下一步"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		  </tr>
		</table>
		</form>
	</div>
 </div></div>
<%@ include file="../../../../common/footer.jsp" %>
</body>
</html>

